from lagom import Container

class Database:
    def query(self):
        return "Data from DB"

class UserService:
    def __init__(self, db: Database):  # 自动注入 Database 实例
        self.db = db

container = Container()
# user_service = container[UserService]  # 自动实例化 UserService 和 Database
db = container[Database]  # 自动实例化 UserService 和 Database

print(db.query())  # 输出: Data from DB